home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
141_01
/
pmklib.doc
< prev
next >
Wrap
Text File
|
1985-03-09
|
4KB
|
134 lines
/* pmklib.c -- personal library -- contents: 84 apr 16
floating-point square root (& dump)
utility fcns - find punct, fill str,
convert filename, hexdump
evaluate & plot functionsa
read & set date/time - Newclock80
primitives for graphics peripheral - TMS9918a
cursor-control for TRS-80 screen w/ Omikron bios
*/
/* fp square root */
fpdump (x) char *x ; { /* hex dump */
char *fpsqrt (z, x) char *z, *x ; { /* z = sqrt (x) */
/* some little utility functions */
int punct (p, s) char *p, *s ; { /* find punct char */
fill (s, n, c) char *s, c ; int n ; { /* fill s with n c's */
fix_name (t, f) char *t, *f ; { /* delete ' ', insert '.' */
spread (t, f) byte *t, *f ; { /* serarate name.ext */
hexdmp (l, n) byte *l ; int n ; { /* debug tool */
/* evaluate & plot function(s) */
comp_pts (npts, nfcns, x, y, llim, delta, f0, f1, f2, f3)
int npts, nfcns ; float *x, *y, *llim, *delta ;
float *(*f0)(), *(*f1)(), *(*f2)(), *(*f3)() ;
{ /* compute array of function-values ; fcns is an array of
pointers to functions returning pointers to float */
plot_pts (npts, nfcns, x, y, scx, scy) int npts, nfcns ;
float *x, *y, *scx, *scy ; { /* plot points */
axes (x, y) { /* plot axis lines */
/* -- fcns to read & set Newclock80 */
syst_d (d) char *d ; { /* system date/time, "yymddhhmmss" */
/* read Newclock80, ASCII format */
read_clock (d_t) byte *d_t ; {
show_clock (d_t) byte *d_t ; {
set_clock (d_t, n) byte *d_t ; int n ; { /* n = offset */
/* - primitives for CHROMAtrs/TMS9918A graphics */
vram_out (addr, data) /* output to vram thru tms9918a */
unsigned addr, data ; {
vram_o_m (addr, data, count) /* out data byte count times */
unsigned addr, data, count ; {
vram_o_2 (addr, data1, data2) /* out 2 data bytes */
unsigned addr, data1, data2 ; {
vram_o_a (addr, pdata, count) /* out count bytes from array */
unsigned addr, count ; char *pdata ; {
int vram_in (addr) /* input from vram thru tms9918a */
unsigned addr ; {
vram_i_a (addr, pdata, count) /* input count bytes */
unsigned addr, count ; char *pdata ; {
vreg_out (reg, data) /* output to vreg in tms9918a */
unsigned reg, data ; {
mode2 () /* set up tms9918 graphics mode 2 */ {
cls (back_gr, fore_gr) /* clear screen */
unsigned back_gr, fore_gr ; {
spr_init () /* clear sprite pattern table */ {
spr_def (pat_num, pat) /* define sprite pattern */
char pat_num, pat[32]; { int i ;
spr_patc (sp_num, pat_num, col) /* set sprite pattern, color */
char sp_num, pat_num, col; {
spr_mov (sp_num, x, y) /* move sprite to x, y */
char sp_num, x, y ; {
ld_font (font) /* load font.def, define characters */
short font[0x60][6] ; /* dot-matrix images, 6 bytes/char */ {
cbar () /* draw colored bars */ {
wr_str (font, x, y, foregr, text) /* write string */
unsigned x, y, foregr ; char **font, *text ; {
wr_ch(font, x, y, foregr, ch) /* write char to screen, G2 */
short font[0x60][6] ; unsigned x, y, foregr, ch ; {
follow (sprite, stk, pat, off, col, x, y)
/* track joystick stk with sprite */
unsigned sprite, stk, pat, off, col, x, y ; {
line (x1, y1, x2, y2, color) /* draw line (x1,y1) to (x2,y2) */
short x1, x2, y1, y2 ; int color ; {
set (h, v, col) /* point on */
unsigned h, v, col ; {
reset (h, v) /* point off */
unsigned h, v ; {
test (h, v) /* test point */
unsigned h, v ; {
xycalc (h, v, offset, b_m) /* find byte & bit for (h, v) */
unsigned h, v, *offset, *b_m ; {
#define TEST 0xA5
vram_test () /* write vram, read back */ {
vram_err (l, r, w) {
/* TRS-80 screen cursor control, etc */
clear () { /* clear screen, home cursor */
cursor (l, c) int l, c ; {
/* position cursor to line l, col c */
curpr (l, c, s) int l, c; char *s ; {
/* position cursor & print string */
regr, text) /* write string */
unsigned x, y, foregr ; char **font, *text ; {
wr_ch(font, x, y, foregr, ch) /* writ